from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
import time

#1,加载环境变量
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mall.settings')

#2,创建celery对象
app = Celery('meiduo')

#3,加载配置项
app.config_from_object('celery_tasks.config', namespace='CELERY')

#4,注册任务,格式: celery_tasks.包名
app.autodiscover_tasks(["celery_tasks.test","celery_tasks.sms","celery_tasks.email","celery_tasks.html"])

#5,启动
# celery -A celery_tasks.main worker -l info


# @app.task(bind=True)
# def debug_task(self):
#     for i in range(0,10):
#         time.sleep(1)
#         print(i)